/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.chl.cid.beans;

import edu.chl.cid.entities.Customer;
import java.beans.*;
import java.io.Serializable;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;

/**
 *
 * @author rhodinj
 */
@Stateless
public class CustomerEJB {

    @PersistenceContext(unitName="sasanshop_pu")
    private EntityManager em;

    public List<Customer> findCustomers() {
        //TypedQuery<Customer> query = em.createNamedQuery("SELECT c FROM Customer c", Customer.class);
        //return query.getResultList();
        Query query = em.createNamedQuery("findAllCustomers");
        return query.getResultList();
    }

    public Customer createCustomer(Customer customer) {
        em.persist(customer);
        return customer;
    }

}
